﻿#region GNU GPL Version 3 License

/// Copyright 2013 Shailesh Lolam
/// 
/// This file Traffic.cs is part of AzEzAuto.
/// 
/// AzEzAuto is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
/// 
/// AzEzAuto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
/// 
/// You should have received a copy of the GNU General Public License along with AzEzAuto. If not, see http://www.gnu.org/licenses/.
/// 
/// History:
/// ______________________________________________________________
/// Created         04-2013             Shailesh Lolam

#endregion
      
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace AzEzAuto.Entities.Network
{
    [XmlRoot("Profile", Namespace="http://schemas.microsoft.com/windowsazure")]
    public class TrafficProfile
    {
        public string DomainName;
        public string Name;
    }

    [XmlRoot("Definition", Namespace = "http://schemas.microsoft.com/windowsazure")]
    public class TrafficDefinition
    {
        public DnsOptions DnsOptions;

        private List<Monitor> _monitors;

        public List<Monitor> Monitors
        {
            get
            {
                if (_monitors == null)
                    _monitors = new List<Monitor>();
                return _monitors;
            }
        }

        public Policy Policy;
    }

    public class EndPoint
    {
        public string DomainName;
        public Status Status;
        public MonitorStatus MonitorStatus;
    }

    public enum MonitorStatus { Online, Offline, Degraded, Unknown }

    public class Policy
    {
        public LoadBalancingMethod LoadBalancingMethod;

        private List<EndPoint> _endPoints;
        public List<EndPoint> EndPoints
        {
            get
            {
                if (_endPoints == null)
                    _endPoints = new List<EndPoint>();
                return _endPoints;
            }
        }
    }

    public class Monitor
    {
        public ushort IntervalInSeconds;
        public ushort TimeoutInSeconds;
        public ushort ToleratedNumberOfFailures;
        public Protocol Protocol;
        public ushort Port;
        public HttpOptions HttpOptions;
    }

    public class HttpOptions
    {
        public HttpVerbs Verb;
        public string RelativePath;
        public string ExpectedStatusCode;
    }

    public class DnsOptions
    {
        public uint TimeToLiveInSeconds;
    }


    [XmlRoot("Definition", Namespace = "http://schemas.microsoft.com/windowsazure")]
    public class DefinitionResponse
    {
        public string Version;
    }

    [XmlRoot("Profile", Namespace = "http://schemas.microsoft.com/windowsazure")]
    public class UpdateProfile
    {
        public Status Status;
        public StatusDetails StatusDetails;
    }

    public class StatusDetails
    {
        public int EnabledVersion;
    }
}
